<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="java.util.List" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

<%
  out.clear();
%>
<!DOCTYPE html>
<html >
<head>
<title>Junseen</title>
	<meta charset="UTF-8" />
	<link rel="shortcut icon" href="/favicon.ico" />
	<link id="easyuiTheme" rel="stylesheet" type="text/css" href="/_resources/easyui/themes/default/easyui.css" />
	<link rel="stylesheet" type="text/css" href="/_resources/easyui/themes/icon.css" />
	<link rel="stylesheet" type="text/css" href="/_resources/easyui/themes/extIcon.css" />
	
	<!-- script -->
	<script type="text/javascript" src="/_resources/easyui/jquery.min.js"></script>
	<script type="text/javascript" src="/_resources/easyui/jquery.easyui.min.js"></script>
	<script type="text/javascript" charset="utf-8" src="/_resources/easyui/locale/easyui-lang-zh_CN.js"></script>
	<script type="text/javascript" src="/_resources/js/jqueryUtils.js"></script>
	
<script type="text/javascript"> 
/*<![CDATA[*/


	
		var mainMenu;
		var mainTabs;
	
		$(function() {
			var treeData = [ {
				text : '客户管理系统',
				iconCls : 'ext_computer',
				children : [ {
					text : '客户信息',
					iconCls : 'ext_folder_wrench',
					attributes : {
						url : "/customer/listCust.do"
					}
				},{
					text : '产品库',
					iconCls : 'ext_folder_wrench',
					attributes : {
						url : "/product/listProduct.do"
					}
				},{
					text : '产品导入',
					iconCls : 'ext_folder_wrench',
					attributes : {
						url : "/product/import.do"
					}
				},{
					text : '图片上传',
					iconCls : 'ext_folder_wrench',
					attributes : {
						url : "/product/uploadedImages.do"
					}
				},{
					text : '类目管理',
					iconCls : 'ext_folder_wrench',
					attributes : {
						url : "/category/listCategory.do"
					}
				}
			]},
			{
				text : '个人',
				iconCls : 'ext_bullet_wrench',
				state:'closed',
				children : [ {
					text : '修改密码',
					iconCls : 'ext_user',
					attributes : {
						url : "user/changePwd.do"
					}
				},{
					text : '退出系统',
					iconCls : 'ext_plugin',
					attributes : {
					  onClick:function(){jsLogout();}
					}
				}]
			}
			];
			mainMenu = $('#mainMenu').tree({
						lines:true,
						data : treeData,
						//parentField : 'pid',
						onClick : function(node) {
							if(node.attributes.onClick) {
								var o={};
								o.fn = node.attributes.onClick;
								o.fn();
							}
							else if (node.attributes.url) {
								var src = node.attributes.url;
								var szTarget = node.attributes.target;
								if(szTarget){
									window.open(src,'');
									return;
								}
								
								var tabs = $('#mainTabs');
								var opts = {
									title : node.text,
									closable : true,
									iconCls : node.iconCls,
									content : '<iframe src="' + src + '" allowTransparency="true" style="border:0;width:100%;height:99%;" frameBorder="0"/>',
									border : false,
									fit : true
								};
								
								if (tabs.tabs('exists', opts.title)) {
									tabs.tabs('select', opts.title);
								} else {
									tabs.tabs('add', opts);
								}
							}
						}
					});
	
			/**
			 * 设置iframe高度
			 */
			setIframeHeight = function(iframe, height) {
				iframe.height = height;
			}
	
			$('#mainLayout').layout('panel', 'center').panel({
				onResize : function(width, height) {
					setIframeHeight('centerIframe', $('#mainLayout').layout('panel', 'center').panel('options').height - 5);
				}
			});
	
			mainTabs = $('#mainTabs').tabs({
				fit : true,
				border : false,
				tools : [{
					text : '刷新',
					iconCls : 'icon-reload',
					handler : function() {
						var panel = mainTabs.tabs('getSelected').panel('panel');
						var frame = panel.find('iframe');
						try {
							if (frame.length > 0) {
								for (var i = 0; i < frame.length; i++) {
									frame[i].contentWindow.document.write('');
									frame[i].contentWindow.close();
									frame[i].src = frame[i].src;
								}							
								if (navigator.userAgent.indexOf("MSIE") > 0) {// IE特有回收内存方法
								try {
										CollectGarbage();
									} catch (e) {
									}
								}
							}
						} catch (e) {
							$.messager.alert('提示', '[' + tab.panel('options').title + ']不可以刷新！', 'error');
						}
					}
				}, {
					//text : '关闭',
					iconCls : 'icon-cancel',
					handler : function() {
						var index = mainTabs.tabs('getTabIndex', mainTabs.tabs('getSelected'));
						var tab = mainTabs.tabs('getTab', index);
						if (tab.panel('options').closable) {
							mainTabs.tabs('close', index);
						} else {
							$.messager.show({
								title:'提示',
								msg:'不可以关闭'
							});
						}
					}
				}, {
					iconCls : 'ext_arrow_up',
					handler : function() {
						mainTabs.tabs({
							tabPosition : 'top'
						});
					}
				}, {
					iconCls : 'ext_arrow_down',
					handler : function() {
						mainTabs.tabs({
							tabPosition : 'bottom'
						});
					}
				} ]
			});
	
		});
		/*]]>*/
	</script>
</head> 

<body id="mainLayout" class="easyui-layout" layout:fragment="content">
	<div data-options="region:'north',href:'layout/north'" style="height: 40px; overflow: hidden;" class="logo"></div>
	<div data-options="region:'west',split:true" title="JUNSEEN" style="width: 180px; padding: 10px;">
		<ul id="mainMenu"></ul>
	</div>
	<div data-options="region:'center'" style="overflow: hidden; ">
		<div id="mainTabs">
		</div>
	</div>	
</body>

</html>